// CQSize.cpp: implementation of the CQSize class.
//
//////////////////////////////////////////////////////////////////////
#include "QDatetime.h"
//////////////////////////////////////////////////////////////////////
QDateTime::QDateTime()
{
	time.wYear = 0;
	time.nMonth = 0;
	time.nDay = 0;
	time.nHour = 0;
	time.nMin = 0;
	time.nSec = 0;	
	time.nMicroSec = 0;
}

QDateTime::QDateTime(QINT aValue)
{
	if(aValue == 0)
	{
		time.wYear = 0;
		time.nMonth = 0;
		time.nDay = 0;
		time.nHour = 0;
		time.nMin = 0;
		time.nSec = 0;
		time.nMicroSec = 0;
	}else
	{
		SetDateFromOther(&aValue);
	}
}

QVOID QDateTime::GetTime(QTime *aTime)
{
	aTime->wYear =	time.wYear;
	aTime->nMonth =	time.nMonth;
	aTime->nDay =	time.nDay;
	aTime->nHour =	time.nHour;
	aTime->nMin =	time.nMin;
	aTime->nSec =	time.nSec;
	aTime->nMicroSec =	time.nMicroSec;
}

QVOID QDateTime::SetDateTime(QTime *aTime)
{
	if(!aTime)
	{
		return ;
	}
	time.wYear = aTime->wYear;
	time.nMonth = aTime->nMonth;
	time.nDay = aTime->nDay;
	time.nHour = aTime->nHour;
	time.nMin = aTime->nMin;
	time.nSec = aTime->nSec;	
	time.nMicroSec = aTime->nMicroSec;
}


QDateTime::QDateTime(QTime *aTime)
{
	SetDateTime(aTime);
}
//	QDateTime::QDateTime(QDateTime aDate)
//	{
//		time.wYear = aDate.wYear;
//		time.nDay = aDate.nDay;
//		time.nHour = aDate.nHour;
//		time.nMin = aDate.nMin;
//		time.nSec = aDate.nSec;
//	}
QDateTime::QDateTime(QDateTime& aDate)
{
		time.wYear = aDate.time.wYear;
		time.nMonth = aDate.time.nMonth;
		time.nDay = aDate.time.nDay;
		time.nHour = aDate.time.nHour;
		time.nMin = aDate.time.nMin;
		time.nSec = aDate.time.nSec;	
		time.nMicroSec = aDate.time.nMicroSec;
}	

QDateTime::QDateTime(const QDateTime& aDate)
{
	time.wYear = aDate.time.wYear;
	time.nMonth = aDate.time.nMonth;
	time.nDay = aDate.time.nDay;
	time.nHour = aDate.time.nHour;
	time.nMin = aDate.time.nMin;
	time.nSec = aDate.time.nSec;	
	time.nMicroSec = aDate.time.nMicroSec;
}

QDateTime::~QDateTime()
{
	//sanford 100522
	time.wYear = 0;
	time.nMonth = 0;
	time.nDay = 0;
	time.nHour = 0;
	time.nMin = 0;
	time.nSec = 0;	
	time.nMicroSec = 0;
}

QINT QDateTime::Compare(QDateTime& aDate)
{
	if(time.wYear > aDate.time.wYear)
	{
		   return 1;
	}
	else if(time.wYear < aDate.time.wYear)
	{
		   return -1;		
	}
	else if(time.nMonth > aDate.time.nMonth)
	{
		   return 1;		
	}
	else if(time.nMonth < aDate.time.nMonth)
	{
		   return -1;		
	}
	else if(time.nDay > aDate.time.nDay)
	{
		   return 1;		
	}
	else if(time.nDay < aDate.time.nDay)
	{
		   return -1;		
	}
	else if(time.nHour > aDate.time.nHour)
	{
		   return 1;		
	}
	else if(time.nHour < aDate.time.nHour)
	{
		   return -1;		
	}
	else if(time.nMin > aDate.time.nMin)
	{
		   return 1;		
	}
	else if(time.nMin < aDate.time.nMin)
	{
		   return -1;		
	}
	else if(time.nSec > aDate.time.nSec)
	{
		   return 1;		
	}
	else if(time.nSec < aDate.time.nSec)
	{
		   return -1;		
	}
	else if(time.nMicroSec > aDate.time.nMicroSec)
	{
		   return 1;		
	}
	else if(time.nMicroSec < aDate.time.nMicroSec)
	{
		   return -1;		
	}
	return 0;
}

QVOID QDateTime::SetDateFromOther(QVOID* pInt)
{
	QTime dt;
	cx_getTimeFromPlatformInt(&dt,pInt);
	QTime *aTime = &dt;
	time.wYear = aTime->wYear;
	time.nMonth = aTime->nMonth;
	time.nDay = aTime->nDay;
	time.nHour = aTime->nHour;
	time.nMin = aTime->nMin;
	time.nSec = aTime->nSec;		
	time.nMicroSec = aTime->nMicroSec;
}

QVOID* QDateTime::GetData()
{           
	return cx_datetime_getData(&time);
}

QINT QDateTime::GetYear()
{
	return time.wYear;
}

QINT QDateTime::GetMonth()
{
	return time.nMonth;
}

QINT QDateTime::GetDay()
{
	return time.nDay;
}

QINT QDateTime::GetHour()
{
	return time.nHour;
}

QINT QDateTime::GetMinute()
{
	return time.nMin;
}

QINT QDateTime::GetSecond()
{
	return time.nSec;
}

QINT QDateTime::GetnMicroSec()
{
	return time.nMicroSec;
}


